package com.atguigu.gmall.mq.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 搭忆长安
 * @version 1.0
 * @date 2021年07月12日 18:40
 * @ClassName:ConfirmReceiver
 * @Description: TODO
 */
@Configuration
public class RabbitConfig {
    /**
     * 新建交换机
     * @return
     */
    @Bean("myExchange")
    public Exchange myExchange(){
        return new TopicExchange("java_exchange", true, false);
       // return ExchangeBuilder.topicExchange("java_exchange").build();
    }

    /**
     * 新建队列
     * @return
     */
    @Bean("myQueue")
    public Queue myQueue(){
        return QueueBuilder.durable("java_queue").build();
    }

    @Bean
    public Binding MyBinding(@Qualifier("myExchange") Exchange myExchange,
                             @Qualifier("myQueue") Queue myQueue){
     return  BindingBuilder.bind(myQueue).to(myExchange).with("java.#").noargs();
    }
}
